Summary: Create a custom object which will open a file using the OpenPanel class. This class will bring up the open panel which will return a pathname to
the file and call the "openFile:" method. The sample code in openFile
will read a file of integers and strings from a disk file into arrays.
Terms:
Dependancies: hello
Discussion: We start by creating an instance of the OpenPanel in the
"new" method. The method "openRequest" is the method that gets executed
after the "Open..." menu is selected. It sends the message:
runModalForTypes:
to the open panel object. It then gets the pathname to the file returned
by sending the "filename" message to the open panel. This filename is
then passed on to a call to the "openFile:" method. The openFile method
is just a wrapper for some generic C code that reads a file of numbers
and strings.
Method:
1) Create a subclass of Object called "MyObject" with a single openRequset:
action and an OpenReq outlet.
2) Create an instance of this object.
3) Add a Window submenu and add an "Open..." submenu to that.
4) Connect the Open menu to an instance of MyObject
5) Add the following code to MyObject.h and MyObject.m